package com.java.base.exercise.current;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author RenPu
 * @Date 2021/8/31 16:06
 * @Version 1.0
 * @Description:
 **/
public class Thread_Locak implements Runnable {

    private static final Lock lock = new ReentrantLock();


    @Override
    public void run() {
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName() + "： 获取到了lock 锁");
            Thread.sleep(5000);
            System.out.println(Thread.currentThread().getName() + "********已苏醒！！！！**********");
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            lock.unlock();
        }


    }


    public static void main(String[] args) {
        Thread_Locak thread_locak = new Thread_Locak();
        new Thread(thread_locak).start();
        new Thread(thread_locak).start();

    }
}
